package com.rfid.mvparms.demo

import com.blankj.utilcode.util.TimeUtils
import org.junit.Test
import java.util.*

/**
 * To work on unit tests, switch the Test Artifact in the Build Variants view.
 */
class ExampleUnitTest {
    @Test
    @Throws(Exception::class)
    fun addition_isCorrect() {
        val string = TimeUtils.getNowMills().toString()
        val sd = string.toByteArray()
        sd.forEach {
            println(it)
        }
        println(TimeUtils.millis2String(getStart()))
        println(TimeUtils.millis2String(getEnd()))
    }

    fun getStart(): Long {
        val calendar = Calendar.getInstance()
        calendar.timeInMillis = TimeUtils.getNowMills()
        calendar.set(Calendar.HOUR_OF_DAY, 0)
        calendar.set(Calendar.MINUTE, 0)
        calendar.set(Calendar.SECOND, 0)
        return calendar.timeInMillis
    }

    fun getEnd(): Long {
        val calendar = Calendar.getInstance()
        calendar.timeInMillis = TimeUtils.getNowMills()
        calendar.set(Calendar.HOUR_OF_DAY, 23)
        calendar.set(Calendar.MINUTE, 59)
        calendar.set(Calendar.SECOND, 59)
        return calendar.timeInMillis
    }


}

class CountingSet2<T>(private val innerSet: MutableCollection<T> = HashSet()) : MutableCollection<T> by innerSet {

    var objectAdded = 0

    override fun add(element: T): Boolean {
        objectAdded++
        return innerSet.add(element)
    }

    override fun addAll(elements: Collection<T>): Boolean {
        objectAdded += elements.size
        return innerSet.addAll(elements)
    }
}